"""Definition of the flowrate content type
"""

from zope.interface import implements

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

# -*- Message Factory Imported Here -*-
from my315ok.flowrate import flowrateMessageFactory as _

from my315ok.flowrate.interfaces import Iflowrate
from my315ok.flowrate.config import PROJECTNAME

flowrateSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-

    atapi.IntegerField(
        'total',
        storage=atapi.AnnotationStorage(),
        widget=atapi.IntegerWidget(
            label=_(u"access total"),
            description=_(u"website access counter"),
        ),
        default=0,
        validators=('isInt'),
    ),


))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

flowrateSchema['title'].storage = atapi.AnnotationStorage()
flowrateSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(flowrateSchema, moveDiscussion=False)


class flowrate(base.ATCTContent):
    """save flow rate result"""
    implements(Iflowrate)

    meta_type = "flowrate"
    schema = flowrateSchema

    title = atapi.ATFieldProperty('title')
    description = atapi.ATFieldProperty('description')

    # -*- Your ATSchema to Python Property Bridges Here ... -*-
    total = atapi.ATFieldProperty('total')


atapi.registerType(flowrate, PROJECTNAME)
